#include "TexturedTriangle.h"

TexturedTriangle::TexturedTriangle(
    ColoredPoint p1, 
    ColoredPoint p2, 
    ColoredPoint p3, 
    vec<float,4> normal,
    GLuint texture, 
    float s1, float s2, float s3,
    float f1, float f2, float f3)
    : Triangle(p1, p2, p3, normal), 
    s1(s1), s2(s2), s3(s3),
    f1(f1), f2(f2), f3(f3),
    texture(texture)
{
}

void TexturedTriangle::Draw()
{
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture);
    glBegin(GL_TRIANGLES);
        glNormal3f(normal[0], normal[1], normal[2]);
	    glTexCoord2f(s1, f1);	
        glVertex3f(point1.position[0], 
                   point1.position[1], 
                   point1.position[2]);
        glTexCoord2f(s2, f2);	
        glVertex3f(point2.position[0], 
                   point2.position[1], 
                   point2.position[2]);
        glTexCoord2f(s3, f3);	
        glVertex3f(point3.position[0], 
                   point3.position[1], 
                   point3.position[2]);
    glEnd();
    glDisable(GL_TEXTURE_2D);
}